#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project : gtmsAutoTestProject 
@File    : pos_order_pay_interface.py
@IDE     : PyCharm 
@Author  : Mario
@Date    : 2022/5/10 15:39 
@Describe: POS订单支付接口入口
"""
from fastapi import APIRouter
from FastApi.dto.pos.orderPay.pos_order_pay_dto import PosOrderPayDtoModel
from FastApi.server.pos.order_pay.pos_order_pay_server import PosOrderPayServer
from Comm.logUtils.logControl import LogHandler

logger = LogHandler().get_logger()
posOrderPay_route = APIRouter()


@posOrderPay_route.post("/order/pay", name="订单支付")
async def posOrderPay(payload: PosOrderPayDtoModel):
    logger.info('请求参数:[{}]'.format(payload))
    pos_pay_request = PosOrderPayServer(payload.brandCode, payload.environment)
    if payload.orderNo is not None:
        response_data = pos_pay_request.single_order_pay(payload.orderNo)
    elif payload.orderNo is None:
        response_data = pos_pay_request.multiple_order_pay()
    else:
        response_data = {"code": "200", "message": "请求参数有误,请检查后重试~"}
    logger.info('接口响应:[{}]'.format(response_data))
    return response_data
